package love.yuanmeng.guetcoalsystem.cotroller;/*
 *   @Studio:CHJY · 源梦科技
 *   @Author:lzl
 *   @Ide:IntelliJ IDEA
 *   @Creation time:2021/10/20 10:12
 */

import love.yuanmeng.guetcoalsystem.pojo.Message;
import love.yuanmeng.guetcoalsystem.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
public class MessageController {

    @Autowired
    MessageService messageService;

    @RequestMapping("/getMessageInfo")
    public List<Message> getMessageInfo(String userid){
        return messageService.getMessageByUserid(userid);
    }

    @RequestMapping("/updateMessage")
    public String updateMessage(@RequestBody Message message){
        int result = messageService.updataMessage(message);
        if(result==1) return "update successfully!";
        return "update failed!";
    }
}
